package com.learn.xueer.app.weight.recyclerview

import android.content.Context
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class SpaceItemDecoration2 : RecyclerView.ItemDecoration {
    private var spacing = 0
    private var context: Context

    constructor(context: Context) {
        this.context = context
        spacing = context.resources.getDimensionPixelSize(6)
    }

    constructor(context: Context, spacing: Int) {
        this.context = context
        this.spacing = spacing
    }

    override fun getItemOffsets(
        outRect: Rect, view: View,
        parent: RecyclerView, state: RecyclerView.State
    ) {
        super.getItemOffsets(outRect, view, parent, state)
        outRect[spacing, spacing, spacing] = spacing
    }
}
